package com.server.service;

import com.server.util.MyFileUtils;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: sunguangzhu
 * Date: 14-2-13
 * Time: 上午11:01
 * To change this template use File | Settings | File Templates.
 */
public class ProjectGeneratorService {
    /**
     * 生成整个项目
     *
     * @throws IOException
     */
    public void generateProject(GeneratorParams generatorParams) throws IOException {
        String path = generatorParams.getPath() ;
        String javaPath = path+"src/main/"+"java";
        String resourcesPath = path+"src/main/"+"resources";
        String testPath = path+"src/test/java";
        //定义输出
        MyFileUtils.makeDir(javaPath);
        MyFileUtils.makeDir(resourcesPath);
        MyFileUtils.makeDir(testPath);
      /*  File cssPath = MyFileUtils.makeDir(path, "webapp");
        File imagesPath = MyFileUtils.makeDir(path, "webapp");
        File jsPath = MyFileUtils.makeDir(path, "webapp");
        File webResourcesPath = new File(path);
        File webinfPath = new File(path);*/

        String sourcePath3 = System.getProperty("user.dir") + "/required/resources";
        String desPath3 = path+ "src/main/resources";
        FileUtils.copyDirectory(new File(sourcePath3), new File(desPath3));

        String sourcePath=System.getProperty("user.dir") + "/required/webapp";
        String desPath=path+"src/main/webapp";
        FileUtils.copyDirectory(new File(sourcePath), new File(desPath));

        //later will been jar
        String sourcePath7 = System.getProperty("user.dir") + "/required/framework";
        String desPath7 = path+ "src/main/java/com/framework";
        FileUtils.copyDirectory(new File(sourcePath7), new File(desPath7));

        //later will been jar
        String sourcePath8 = System.getProperty("user.dir") + "/required/generator";
        String desPath8 = path+ "src/main/java/generator";
        FileUtils.copyDirectory(new File(sourcePath8), new File(desPath8));
        /*
        String sourcePath2=System.getProperty("user.dir") + "/src/test/java/generator";
        String desPath2=hardDisk+projectName+"/src/test/java/generator";
        FileUtils.copyDirectory(new File(sourcePath2), new File(desPath2));

        String sourcePath4=System.getProperty("user.dir") + "/src/main/java/generator/model";
        String desPath4=hardDisk+projectName+"/src/main/java/generator/model";
        FileUtils.copyDirectory(new File(sourcePath4), new File(desPath4));

        String sourcePath5=System.getProperty("user.dir") + "/src/main/java/generator/database";
        String desPath5=hardDisk+projectName+"/src/main/java/generator/database";
        FileUtils.copyDirectory(new File(sourcePath5), new File(desPath5));

        String sourcePath6=System.getProperty("user.dir") + "/template";
        String desPath6=hardDisk+projectName+"/template";
        FileUtils.copyDirectory(new File(sourcePath6), new File(desPath6));*/



    }


}
